package vip.zhenzicheng.nettyadv.cryocodec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import vip.zhenzicheng.nettyadv.vo.MyMessage;

/**
 * @author zhenzicheng
 * @date 2022-06-14 09:26
 */
public class KryoEncoder extends MessageToByteEncoder<MyMessage> {

  @Override
  protected void encode(ChannelHandlerContext ctx, MyMessage message, ByteBuf out) throws Exception {
    KryoSerializer.serialize(message, out);
    ctx.flush();
  }
}
